package com.jiepos.mpos.biz.transaction.controller;

import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import com.jiepos.mpos.biz.transaction.service.AppLogAbstractService;
import com.jiepos.mpos.common.entity.App_Ins_InfEntity;
import com.jiepos.mpos.common.entity.App_Log_AbstractEntity;
import com.jiepos.mpos.core.controller.BaseController;
import com.jiepos.mpos.core.entity.Pagination;
import com.jiepos.mpos.core.util.StringUtils;

@Controller
@RequestMapping("/logabstract")
public class LogAbstractController extends BaseController {
	/** 导出文件名称*/
	private static String EXCEL_LOGABSTRACT_NAME = "提现申请流水.xls";

	private static String EXCEL_LOGABSTRACT_SUM_NAME = "提现手续费汇总.xls";

	@Autowired
	private AppLogAbstractService appLogAbstractService;
	
	/**
	 * 获取提现申请页面
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping("/getLogAbstractList.do")
	public ModelAndView getLogAbstractList(HttpServletRequest request, HttpServletResponse response){
		
		ModelAndView model = new ModelAndView("/module/transaction/logabstract/logabstract_list");
		return super.getDetail(request, response, model);
	}
	
	/**
	 * 获取提现申请Json
	 * @param request
	 * @param response
	 * @param pagination
	 * @param abstractEntity
	 * @return
	 */
	@RequestMapping("/getLogAbstractListJson.do")
	public Map<String, Object> getLogAbstractListJson(HttpServletRequest request, HttpServletResponse response,
			Pagination pagination,App_Log_AbstractEntity abstractEntity,String custom_no,String phone,String name,String settle_acct,
									  String apply_startDate,String apply_endDate,
									  String audit_startDate,String audit_endDate,String rspcode,String stlcode){
		
		return appLogAbstractService.getLogAbstractListJson(pagination,request,abstractEntity,custom_no,phone,name,settle_acct,apply_startDate,apply_endDate,audit_startDate,audit_endDate,rspcode,stlcode);
	}


	/**
	 *提现申请流水导出数据
	 * @param request
	 * @param response
	 * @param abstractEntity
	 * @return
	 */
	@RequestMapping("/exportLogAbstractList.do")
	@ResponseBody
	public void exportLogAbstractList(HttpServletRequest request, HttpServletResponse response, Pagination pagination,
									  App_Log_AbstractEntity abstractEntity,String custom_no,String phone,String name,String settle_acct,
									  String apply_startDate,String apply_endDate,
									  String audit_startDate,String audit_endDate,String rspcode, String stlcode) {
		super.clearCookie(request, response);
		String msg = appLogAbstractService.executeSaveLogAbstractList( EXCEL_LOGABSTRACT_NAME, abstractEntity,
				custom_no, phone, name, settle_acct,apply_startDate,apply_endDate,audit_startDate,audit_endDate,rspcode,stlcode);
		if (StringUtils.isBlank(msg)) {
			super.setFileParam(request, response, EXCEL_LOGABSTRACT_NAME);
		} else {
			super.setErrorFileParam(request, response, msg);
		}
	}


	/**
	 * 获取手续费汇总页面
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping("/logabstractsumList.do")
	public ModelAndView getLogabstractSumList(HttpServletRequest request, HttpServletResponse response){

		ModelAndView model = new ModelAndView("/module/transaction/logabstractsum/logabstractsum_list");
		return super.getDetail(request, response, model);
	}

	/**
	 * 获取提现申请Json
	 * @param request
	 * @param response
	 * @param pagination
	 * @param abstractEntity
	 * @return
	 */
	@RequestMapping("/getLogAbstractSumListJson.do")
	public Map<String, Object> getLogabstractSumListJson(HttpServletRequest request, HttpServletResponse response,
													  Pagination pagination,App_Log_AbstractEntity abstractEntity,App_Ins_InfEntity infEntity,
													  String apply_startDate,String apply_endDate){

		return appLogAbstractService.getLogAbstractSumListJson(pagination,request,abstractEntity,infEntity,apply_startDate,apply_endDate);
	}

	/**
	 *提现手续费导出数据
	 * @param request
	 * @param response
	 * @param abstractEntity
	 * @return
	 */
	@RequestMapping("/exportLogAbstractSumList.do")
	@ResponseBody
	public void exportLogAbstractSumList(HttpServletRequest request, HttpServletResponse response,
										 Pagination pagination,App_Log_AbstractEntity abstractEntity,App_Ins_InfEntity infEntity,
										 String apply_startDate,String apply_endDate) {
		super.clearCookie(request, response);
		String msg = appLogAbstractService.executeSaveLogAbstractSumList( request,EXCEL_LOGABSTRACT_SUM_NAME, abstractEntity,infEntity,
				apply_startDate,apply_endDate);
		if (StringUtils.isBlank(msg)) {
			super.setFileParam(request, response, EXCEL_LOGABSTRACT_SUM_NAME);
		} else {
			super.setErrorFileParam(request, response, msg);
		}
	}

	/**
	 * 获取汇总数据
	 *
	 * @param request
	 * @param response
	 * @param pagination
	 * @return
	 */
	@RequestMapping("/getLogAbstractSumTotal.do")
	@ResponseBody
	public Map getLogStlMchntInfoTotal(HttpServletRequest request, HttpServletResponse response,
									   Pagination pagination,App_Log_AbstractEntity abstractEntity,App_Ins_InfEntity infEntity,
									   String apply_startDate,String apply_endDate) {
		return appLogAbstractService.getLogAbstractSumTotal(request, abstractEntity, infEntity,apply_startDate,
				apply_endDate);
	}
}
